package matossian.j2se6.examples.collections;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Maps {
	
	/*
	 * Solo quienes implementan Iterable pueden ser iterados con foreach.
	 * Collection implementa Iterable, asi que tanto Collection como sus subinterfaces son todas iterables.
	 * Map no extiende de Iterable.
	 */

	public static void main(String[] args) {
		Map<String, String> s = new HashMap<String, String>();
		String a = "a";
		String b = "b";
		String c = "c";
		s.put(a, a);
		s.put(b, b);
		s.put(c, c);
		System.out.println(s.containsKey(b));
		s.remove(b);
		System.out.println(s.containsKey(b));
		for(Map.Entry<String, String> entry : s.entrySet()) {
			System.out.println("\t- " + "<" + entry.getKey() + ", " + entry.getValue() + ">");
		}
		
		Map<String, String> s2 = new TreeMap<String, String>();
		s2.put(a, a);
		s2.put(b, b);
		s2.put(c, c);
		System.out.println(s2.containsKey(b));
		s2.remove(b);
		System.out.println(s2.containsKey(b));
		for(Map.Entry<String, String> entry : s2.entrySet()) {
			System.out.println("\t- " + "<" + entry.getKey() + ", " + entry.getValue() + ">");
		}
	}

}
